Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change/timezone locale #6

Merged
merged 7 commits into from
Feb 8, 2017

Conversation

shepherdsam
Copy link
Contributor

No description provided.

lib/index.js Outdated
options.locale = locale;
} else if (locale) {
options = locale;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused why we need this if/else statement?

This appears to be an addition to the API so why not just make every caller pass in an object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My original thinking was to mimic the second param of SugarDate.create which behaves like this. But I do like the idea of not having a mixed type as a parameter.

lib/index.js Outdated
* @return {Object} an object containing the parsed date, or the passed field if it was not a String.
*/
Utils.parseDateTimeField = function(field) {
Utils.parseDateTimeField = function(field, locale) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment in Flow XO core, it would be good to allow the SugarDate creation to be customised for the lifetime of this function invocation by passing in an optional dateCreator fn.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I wrote this comment, this feature has been implemented! So please ignore. 😄

lib/index.js Outdated
// Makes unit testing possible, by allowing this
// function to be mocked.
return Date.future(str);
return SugarDate.create(str, _.assign({future: true}, options));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be better written as:

return SugarDate.create(str, _.assign({}, options, {future: true}));

The advantage here is that an options object containing future: false would not cause issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! I see what you are saying.

Fixed a potential bug with gettign the future date.
`moment` is now returned and is a timezone aware moment.js object.
@shepherdsam shepherdsam merged commit a7f8d98 into flowxo:master Feb 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants